package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo5Filter {
  def main(args: Array[String]): Unit = {

    val conf: SparkConf = new SparkConf()
      .setAppName("make")
      .setMaster("local")


    val sc = new SparkContext(conf)


    val rdd1: RDD[Int] = sc.parallelize(List(1, 2, 3, 4, 5, 6, 7, 8, 9))

    /**
      * filter : 过滤数据
      *
      * 当函数返回true的时候保留数据
      * 当函数返回false的时候过滤数据
      *
      */

    val filterRDD: RDD[Int] = rdd1.filter(i => i % 2 == 0)



    filterRDD.foreach(println)

  }

}
